package com.example.demo.modules.redis.controller;

import com.example.demo.modules.redis.service.redisService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/redis/test")
@Api(tags = "redis模块")
public class RedisController {
    @Resource
    private redisService redisService;

    @PostMapping("/saveKV")
    @ApiOperation(value = "插入一个键值对", notes = "插入一个键值对")
    public String saveKV(String key, String value){
        return redisService.save(key, value);
    }

    @DeleteMapping("/deleteK")
    @ApiOperation(value = "删除键", notes = "删除键")
    public String deleteK(String key){
        return redisService.delete(key);
    }

}
